package com.nl.utils;

import org.apache.flink.shaded.guava18.com.google.common.hash.BloomFilter;
import org.apache.flink.shaded.guava18.com.google.common.hash.Funnels;

/**
 * @author shihb
 * @date 2019/12/20 13:27
 * Google布隆过滤器的使用
 */
public class BloomFilterDemo {

  public static void main(String[] args) {
    // 1.初始话 BloomFilter提供了create静态方法来创建BloomFilter实例
    // 可以传入三个参数第一个指定类型，第二个期望的插入树，第三个期望的误检率(默认0.03D)
    BloomFilter<Long> bloomFilter = BloomFilter.create(Funnels.longFunnel(), 6);
    Long l=111111L;
    // 2.判断是否存在mightContain
    System.out.println(bloomFilter.mightContain(l));
    // 3.存值
    bloomFilter.put(l);
    System.out.println(bloomFilter.mightContain(l));
  }

}
